define(["jquery","vue",'common'],function ($,Vue,common){
    const Controller = {
        index:function (){
            var app = Vue.createApp({
                data(){
                    return {
                        height:300,
                        form:{
                            username:"",
                            nickname:"",
                            password:"",
                            avatar:"",
                            email:"",
                        },
                        dataObj:{
                            total:0,
                            rows:[],
                            limit:10,
                            page:1
                        },
                        additional:{
                            group:[]
                        },
                        selectIds:[],
                        user_id:'',
                        uploadurl:Config.upload.uploadurl
                    }
                },
                created(){
                    // console.log(Config.upload.uploadurl)
                    let that = this;
                    let url = Config.moduleurl+'/'+Config.controllername+`/index`;
                    $.get(url,function (res){
                        // console.log('rrrrrrrrrrrr',res)

                        if(res.code==1){
                            that.user_id = res.data.id
                            let form = that.form||{};
                            for(let key in form){
                                if(key!='password'){
                                    form[key] = res.data[key]
                                }
                            }
                            that.form = form
                        }
                    })
                    this.getLogs()
                    // that.height =  document.body.clientHeight -130
                    setTimeout(()=>{
                        that.height =  document.body.clientHeight -130
                    },50)
                    // console.log(Config,'ccccccccccccccccc')
                },
                methods:{
                    ...common,
                    getLogs(){
                        let that = this
                        let data = {
                            page:this.dataObj.page,
                            limit:this.dataObj.limit,
                        }
                        let url = Config.moduleurl+'/'+Config.controllername+`/get_log`;
                        $.get(url,data,function (res){
                            // console.log(res,'rrrrrrrrrrrrrrrrr')
                            if(res.code==1){
                                that.dataObj.rows = res.data.rows
                                that.dataObj.total = res.data.total
                            }
                        })
                    },
                    handleCurrentChange(e){
                        this.dataObj.page = e
                        this.getLogs()
                    },
                    handleDelete(row){
                        console.log(Config)
                        let url = Config.moduleurl+`/auth.adminlog/del?ids=${row.id}`
                        let that = this;
                        this.$messageBox.confirm('确定删除吗？', '提示', {
                            confirmButtonText: '确定',
                            cancelButtonText: '取消',
                            type: 'warning'
                        }).then(() => {
                            $.get(url,function (res){
                                that.$message({
                                    type: 'success',
                                    message: '删除成功!'
                                });
                                that.getLogs()
                            })
                        }).catch((e) => {
                            that.$message({
                                type: 'error',
                                message: e.msg?e.msg:"操作失败"
                            });
                        });

                    },
                    handleDeleteAll(){
                        let selectIds = this.copy(this.selectIds)
                        if(selectIds.length==0){
                            layer.msg('请选择要删除的数据')
                            return
                        }
                        if(Array.isArray(selectIds)){
                            selectIds = selectIds.join(',')
                        }
                        let url = Config.moduleurl+`/auth.adminlog/del?ids=${selectIds}`
                        let that = this;
                        this.$messageBox.confirm('确定删除吗？', '提示', {
                            confirmButtonText: '确定',
                            cancelButtonText: '取消',
                            type: 'warning'
                        }).then(() => {
                            $.get(url,function (res){
                                that.$message({
                                    type: 'success',
                                    message: '删除成功!'
                                });
                                that.getLogs()
                            })
                        }).catch((e) => {
                            that.$message({
                                type: 'error',
                                message: '取消删除!'
                            });
                        })
                        // $.get(url,function (res){
                        //     layer.msg(res.msg)
                        //     that.getLogs()
                        // })
                    },
                    onSubmitUser(){
                        let form = this.form;
                        let data = {row:form}
                        let user_id = this.user_id
                        let url = Config.moduleurl+'/'+Config.controllername+`/save`;
                        $.post(url,data,function (res){
                            window.parent.getUserInfo()
                            layer.msg(res.msg?res.msg:"修改成功")
                            // parent.location.reload();
                        })
                    }

                }
            })
           common.loadELEMENT(app,false)
            
            app.mount("#app");
        }
    }
    return Controller;
})